﻿namespace SoftwarePackages

open System
open System.Text

type PackageVersion (package: string, version: DayVersion) =
    member this.Package = package
    member this.Version = version
    
    override this.ToString() =
        package + "-" + version.ToString()
    
    static member Parse (input: string) =
        let dateIndex = input.IndexOf('-')
        if dateIndex < 0 then
            FormatException() |> raise
        else
            let name = input.Substring(0, dateIndex)
            let input = input.Substring(dateIndex + 1)
            let version = DayVersion.Parse input
            PackageVersion(name, version)
